#!/bin/bash
#install docker-ce
basepath=$(pwd)
source ${basepath}/conf/base.sh
env="$1"
container="$2"
if [ "$1" != "start" -a "$1" != "stop" -a "$1" != "restart" ];then
  echo -e "\033[032m 【`hostname` ERROR : $1,容器启动失败 】\033[0m"
  log_user
  exit 1
else
  a=`docker ps -a --format  {{.Names}}`
    case $1 in
        'start')
             for i in $a
                do
                   if [ "$2" == "$i"  ];then
                           container_all "start" "$2"
                    fi
             done
             if [ "$2" == "" ];then
                           container_start
             fi ;;
        'stop')
             for ii in $a
                do
                  if [ "$2" == "$ii"  ];then
                           container_all "stop" "$2"
                  fi
             done
             if [ "$2" == "" ];then
                 container_stop
             fi ;;
    'restart')
             for iii in $a
                 do
                   if [ "$2" == "$iii"  ];then
                            container_all "restart" "$2"
                   fi
             done
        if [ "$2" == "" ];then
                container_stop
                container_rm
                container_run
        fi ;;
  esac
fi